package com.example.pinkcat.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.pinkcat.fragment.shouye.Fragment_fenqu;
import com.example.pinkcat.fragment.shouye.Fragment_yingshi;
import com.example.pinkcat.fragment.shouye.Fragment_zhuifan;
import com.example.pinkcat.fragment.shouye.Fragment_remen;
import com.example.pinkcat.fragment.shouye.Fragment_tuijian;

public class Tuijianye_FragmentPagerAdapter extends FragmentPagerAdapter {

    private String[] items = new String[]{"推荐","热门","追番","影视","分区"};

    public Tuijianye_FragmentPagerAdapter(@NonNull  FragmentManager fm){
        super(fm);

    }

    /**
     推荐 热门 追番 影视 分区
     **/

    @NonNull
    @Override
    public Fragment getItem(int position) {
        if(position == 1){
            return new Fragment_remen();
        } else if(position == 2){
            return new Fragment_zhuifan();
        }else if(position == 3){
            return new Fragment_yingshi();
        }else if(position == 4){
            return new Fragment_fenqu();
        }
            return new Fragment_tuijian();
        }

    @Override
    public int getCount() {
        return items.length;
    }

    //ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
   @Override
    public CharSequence getPageTitle(int position){
        return items[position];
   }
}
